package com.example.courseapp.activity;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentTransaction;

import com.example.courseapp.R;
import com.example.courseapp.fragment.HealthFragment;
import com.example.courseapp.fragment.MineFragment;

public class MainActivity extends AppCompatActivity {

    HealthFragment resourceFragment;
    MineFragment mine;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        resourceFragment = HealthFragment.newInstance();
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.add(R.id.container, resourceFragment);
        transaction.commit();
        mine = MineFragment.newInstance();

        findViewById(R.id.mine).setOnClickListener(view -> {
            FragmentTransaction transaction1 = getSupportFragmentManager().beginTransaction();
            transaction1.replace(R.id.container, mine);
            transaction1.commit();
        });

        findViewById(R.id.home).setOnClickListener(view -> {
            FragmentTransaction transaction1 = getSupportFragmentManager().beginTransaction();
            transaction1.replace(R.id.container, resourceFragment);
            transaction1.commit();
        });



    }
}